﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FrameWorkSong;
using LitJson;

public class httpExamples :MonoBehaviourSimplify
{

    public override void OnBeforeDestroy()
    {
        UnRegisterMsg("getinfo");//注销"getinfo"方法
    }

    // Start is called before the first frame update
    void Start()
    {
    
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            string url = "http://192.168.11.106:86/hello/sever.php";
            HttpRequest.Instance.webGet(url, getInfo);
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            postInfo();
        }
    }
    void getInfo(object data)
    {
        Debug.Log(data);
    }

    void postInfo()
    {
        Dictionary<string, string> info = new Dictionary<string, string>();
        info.Add("name", "名称");
        info.Add("id", "ID");
        string JsonInfo = JsonMapper.ToJson(info);
        string url = "http://192.168.11.106:86/hello/sever.php";
        HttpRequest.Instance.webPost(url, JsonInfo, getInfo);
    }
}
